package cn.italkcloud.cph.controller;


import cn.italkcloud.cph.config.exception.BusinessException;
import cn.italkcloud.cph.config.sys.RequestContent;
import cn.italkcloud.cph.entity.dto.UserAuthDTO;

/**
 * @author dominate
 * @since 2024/1/3
 */
public class BaseController {


    /**
     * 获取用户
     * 未登录或Token检查不通过都会抛出相应异常
     *
     * @return 登录用户
     * @throws BusinessException 登录状态异常
     */
    public UserAuthDTO getUser() throws BusinessException {
        return RequestContent.getUser();
    }

    /**
     * 获取用户ID
     * 未登录或Token检查不通过都会抛出相应异常
     *
     * @return 用户ID
     * @throws BusinessException 登录状态异常
     */
    public int getAccountId() throws BusinessException {
        return getUser().getAccountId();
    }

    public String getToken() {
        return RequestContent.getToken();
    }


}
